#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@文件    :run.py
@说明    :为保证正确获取到数据，请先抓包Pott APP 将Cookie中的SessionID填入下方
@时间    :2020/08/21 10:48:01
@作者    :DanceDJ
@微信公众号    :给我一碗炒饭
@版本    :1.0
'''
from flask import Flask,Response
app = Flask(__name__)
from pott.pott import *

session=""

@app.route("/")
def hello():
    return "Hello World!"

@app.route('/api/getinfo/<uid>')
def getinfo(uid):
    if(session==""):
        returndata={"code":"-1","count":0,"msg":"未完成配置，请查看文档","data":[]}
    else:
        userdata=profile(uid,session)
        if(userdata==0):
            returndata={"code":"-1","count":0,"msg":"用户不存在","data":[]}
        else:
            goneCitydata=goneCityV2(uid,session)
            imagesdata=userImages(uid,0,session)
            returndata={"code":"0000","count":0,"msg":"成功","data":[]}
            returndata['userdata']=userdata
            returndata['goneCitydata']=goneCitydata
            returndata['data']=imagesdata
            returndata['count']=len(imagesdata)
    return Response(json.dumps(returndata),  mimetype='application/json' ,content_type="text/plain;charset=UTF-8")
    
if __name__ == "__main__":
    app.config['JSON_AS_ASCII'] = False
    app.run()